package 蓝桥算法;

import 二叉树.TreeNode;
import 队列.LinkedListQueue;

import java.util.ArrayList;
import java.util.List;

public class day18 {
    public void checkFun02(TreeNode node){
        List<List<TreeNode>> resList=new ArrayList<>();//存集合的数组
        if(node==null){
            return;
        }
        LinkedListQueue<TreeNode>queue=new LinkedListQueue<>();
        queue.offer(node);
        while(!queue.isEmpty()){
            int size=queue.size;
            List<TreeNode>list=new ArrayList<>();
            while(size>0){
                TreeNode tmpNode=queue.poll();
                list.add(tmpNode);//存入值
                if(tmpNode.left!=null){
                    queue.offer(tmpNode.left);
                }
                if(tmpNode.right!=null){
                    queue.offer(tmpNode.right);
                }
                size--;
            }
            resList.add(list);
        }
    }
    public TreeNode investTree(TreeNode root){
        if(root==null){
            return  null;
        }
        investTree(root.left);
        investTree(root.right);
        changeChild(root);
        return root;
    }
    public void changeChild(TreeNode root){
        TreeNode tep=root.left;
        root.left=root.right;
        root.right=tep;
    }
    
}
